{extend name="../../public/admin"}
{block name="title"}数据字典{/block}
{block name="css"}
<link rel="stylesheet" href="__PUBLIC__/admin/css/index.dictionaries.css">
{/block}
{block name="body"}
<div id="container">


    <div class="clearfix"></div>
    <div style="height: 20px;"></div>
    <div class="table-responsive" id="header">
        <table class="table table-bordered table-hover" v-cloak>
            <thead>
            <tr class="active ">
                <th colspan="10" class="text-left">
                    <a href="javascript:;" @click="addData()" class="btn btn-info btn-sm"><i class="fa fa-plus"></i>
                        {:lang('添加')}</a>
                    <a href="javascript:;" @click="up()" class="btn btn-success btn-sm">
                        <i class="fa fa-edit"></i> 项目资料
                    </a>
                    <span class="fa-pull-right">总 <strong>{{list.length}}</strong> 条</span>
                </th>
            </tr>
            <tr class="active">
                <th>{:lang('序号')}</th>
                <th>{:lang('拨付日期')}</th>
                <th>中标金额</th>
                <th>决算金额</th>
                <th>拨付金额</th>
                <th>欠拨金额</th>
                <th>拨款记录</th>
                <th>{:lang('状态')}</th>
                <th>{:lang('操作')}</th>
            </tr>
            </thead>
            <tbody id="tbody">
            <template v-for="(key,index) in list">
                <tr>
                    <td>{{index+1}}</td>
                    <td>{{key.time}}</td>
                    <td>
                        <a href="javascritp:;" onclick="loock_img($(this))" data-img="{$data.budgetary_price_img}">{$data.budgetary_price}</a>
                    </td>
                    <td>
                        <a href="javascritp:;" onclick="loock_img($(this))" data-img="{$data.determine_mobile_img}">{$data.determine_mobile}</a>
                    </td>
                    <td>{{key.money}}</td>
                    <td></td>

                    <td>
                        <a href="javascript:;" onclick="loock_img($(this))" :data-img="key.money_img">{:lang('查看')}</a>
                    </td>
                    <td>
                        {{key.state == 0?"{:lang('待审核')}":key.state == 1?"{:lang('通过')}":"{:lang('拒绝')}"}}

                    </td>
                    <td>
                        <template v-if="key.state == 0 "><!--待审核-->
                            <a href="javascript:;" title="{:lang('通过')}" @click="upType(index,1)"><i class="fa fa-check"></i></a>
                            <a href="javascript:;" title="{:lang('拒绝')}" @click="upType(index,2)"><i class="fa fa-close"></i></a>
                        </template>
                        <template v-else-if="key.state == 2"> <!--拒绝-->
                            <a href="javascript:;" title="{:lang('修改')}" @click="up_info(index)"><i class="fa fa-edit"></i></a>
                        </template>
                        <template v-else-if="key.state == 1">
                            <a href="javascript:;" title="{:lang('返回到拒绝')}" @click="upType(index,2)"><i class="fa fa-mail-reply"></i></a>
                        </template>
                    </td>
                </tr>
            </template>
            </tbody>


            <!--详细-->
        </table>



    </div>
    <div class="row">
        <div class="col-xs-4">
            {:lang('施工企业')}：{$data.user_name}<br/>
            企业法人：{$data.user_representative}<br/>
            固定电话：{$data.mobile}<br/>
            联系方式：{$data.user_representative_mobile}
        </div>
        <div class="col-xs-4">
            项目经理：{$data.manager}<br/>
            证件号码：{$data.certificates}<br/>
            联系方式：{$data.certificates_mobile1}<br/>
            联系方式：{$data.certificates_mobile2}

        </div>
    </div>

</div>
{/block}
{block name="js"}


<script>

    var app = new Vue({
        el: '#container',
        data: {
            list: [],
            chu:0
        }
    });

    //修改拨出错误
    app.up_info = (index)=>{
        layer.open({
            type:2,
            area:['500px','500px'],
            content:"{:url('count/up_info',['on'=>'true'])}?id="+app.list[index].id
        })
    }
    //审核
    app.upType =(i,state)=>{
        layer.confirm("{:lang('是否确定')}",function () {
            $.post("{:url('money_update')}",{id:app.list[i].id,state:state},function (da) {
                console.log(da);
                if (da == 1) {
                    $.post("{:url('count/over_sum')}",{id:{$Request.param.id}}, function (da) {
                        app.chu = da;
                    });
                    layer.msg("{:lang('成功')}",{icon:1,offset:'rb'});
                }
                else{
                    layer.msg("{:lang('失败')}",{icon:2,offset:'rb',end:function () {
                            //location.reload();
                        }});
                }
            })
            app.list[i].state = state;
        })
    }


    get_data();

    //获取数据
    function get_data() {
        var index = layer.load(1);
        $.get("{:url('count/rmb',['id'=>$Request.param.id])}", function (da) {
            app.list = da;
            layer.close(index);
            app.$nextTick(function(){
                var shiji_money = parseFloat('{$data.determine_mobile}') > 1 ?parseFloat('{$data.determine_mobile}'):parseFloat('{$data.budgetary_price}')
                $.each(app.list,function(i,n){
                    shiji_money = shiji_money-(app.list[i].money);
                    $('#tbody').find('tr').eq(i).find('td').eq(5).html(shiji_money.toFixed(2));
                });
            })
        });
        $.post("{:url('count/over_sum')}",{id:{$Request.param.id}}, function (da) {
            app.chu = da;
        });

    }

    //查看图片
    app.imgLock = (url)=>{
        layer.open({
            type:2,
            title:'查看文件',
            shift:'3',
            area:['100%','100%'],
            content:url
        })
    }

    app.up=()=>{
        layer.open({
            type:2,
            area:['100%','100%'],
            title:false,
            closeBtn:false,
            content:"{:url('rmb_info',['on'=>'true','id'=>$data.id])}"
        })

    }



    //添加内容
    app.addData = () => {
        layer.open({
            type:2,
            area:['500px','500px'],
            content:"{:url('count/add_info',['on'=>'true','id'=>$data.id])}"
        })
    }

    //完善资料
    if('{$data.user_name}' == ''){
        layer.alert('请完善项目资料',function () {
            layer.closeAll();
            app.up();
        });
    }
</script>
{/block}